
      <div class="box">
            <div class="box-header">
              <form class="form-inline" style="float: left" action="/pushup/add" method="get">
                <div class="form-group">
                  <label class="sr-only" for="username">username</label>
                  <input type="text" class="form-control" name="username" id="username" placeholder="谁违纪">
                </div>
                <div class="form-group">
                  <label class="sr-only" for="run">Password</label>
                  <input type="number" class="form-control" name="run" id="run" placeholder="多少个">
                </div>
                <button type="submit" class="btn btn-info btn-sm">添加记录</button>
                <a href="/pushup/updateMany?num=10">
                <button type="button" class="btn btn-success btn-sm">+10</button></a>
                  <a href="/pushup/updateMany?num=-10">
                  <button type="button" class="btn btn-success btn-sm">-10</button></a>
              </form>
              <form class="form-inline" style="float: left;margin-left:12px;" action="/pushup/search" method="get">
                <div class="form-group">
                  <label class="sr-only" for="username">username</label>
                  <input type="text" class="form-control" name="username" id="username" placeholder="搜索违纪">
                </div>
                <button type="submit" class="btn btn-info btn-sm">搜索</button>
              </form>
              <ul style="float: left;list-style:none">
                <% for(var item of kind) { %>
                  <li style="display: inline-block">
                    <a href="/pushup/run?num=<%= item %>" > <%= item %> </a>
                  </li>
                <% } %>
              </ul>
            </div>
            <!-- /.box-header -->
            <div class="box-body no-padding">
              <table class="table table-condensed table-striped table-bordered">
                <tbody>
                <tr>
                  <th class="text-center">
                      <div class="checkbox">
                          <label>
                            <input type="checkbox">
                          </label>
                        </div>
                  </th>
                  <th class="text-center">序号</th>
                  <th class="text-center">姓名</th>
                  <th class="text-center">数量</th>
                  <th class="text-center">操作</th>
                </tr>
                <% if (result.length == 0) { %>
                  <tr >
                    <td class="text-center" colspan="5">暂无数据</td>
                  </tr>
                <% } else { %>
                  <% for (var i = 0; i < result.length; i++) { %>
                    <% if (result[i].run > 40) { %>
                      <tr style="background:#f00">
                          <td class="text-center">
                              <div class="checkbox">
                                  <label>
                                    <input type="checkbox">
                                  </label>
                                </div>
                          </td>
                        <td class="text-center"><%= i + 1 %></td>
                        <td class="text-center">
                          <a href="/pushup/detail?username=<%= result[i].username %>">
                            <%= result[i].username %>
                          </a>
                        </td>
                        <td class="text-center" id="test<%= i %>">
                          <%= result[i].run %>
                        </td>
                        <td class="text-center">
                          <button class="btn btn-warning btn-xs" onclick="edit(<%= i %>, '<%= result[i].username %>', <%= result[i].run %>)">编辑</button>
                          <a href="/pushup/delete?username=<%= result[i].username %>"><button class="btn btn-danger btn-xs">删除</button></a>
                        </td>
                      </tr>
                    <% } else { %>
                      <tr>
                          <td class="text-center">
                              <div class="checkbox">
                                  <label>
                                    <input type="checkbox">
                                  </label>
                                </div>
                          </td>
                        <td class="text-center"><%= i + 1 %></td>
                        <td class="text-center">
                            <a href="/pushup/detail?username=<%= result[i].username %>">
                          <%= result[i].username %></a>
                        </td>
                        <td class="text-center" id="test<%= i %>">
                          <%= result[i].run %>
                        </td>
                        <td class="text-center">
                          <button class="btn btn-warning btn-xs" onclick="edit(<%= i %>, '<%= result[i].username %>', <%= result[i].run %>)">编辑</button>
                          <a href="/pushup/delete?username=<%= result[i].username %>"><button class="btn btn-danger btn-xs">删除</button></a>
                        </td>
                      </tr>
                    <% } %>
                  <% } %>

                <% } %>
                
                </tbody></table>
                <nav aria-label="...">
                  <ul class="pager">
                    <li><a href="javascript:void(0)" onclick="prevPage('<%= pageCode %>')">上一页</a></li>
                    <li><a href="javascript:void(0)" onclick="nextPage('<%= pageCode %>')">下一页</a></li>
                  </ul>
                </nav>
            </div>
            <!-- /.box-body -->
          </div>
<script type="text/javascript">
  function edit (index, username, run) {
    // console.log(username, index)
    $('#test' + index).html(`
      <input type="number" name="run" id="run${index}" value="${run}" />
      <button id="btn${index}" class="btn btn-danger btn-xs" >确定</button><button id="clear${index}" class="btn btn-warning btn-xs" >清空</button>`)

    $("#btn" + index).on('click', function () {
      console.log(username, index)
      var runNum = $('#run' + index).val();
      window.location.href = `/pushup/updateOne?username=${username}&run=${runNum}`;
    })
    $("#clear" + index).on('click', function () {
      window.location.href = `/pushup/updateOne?username=${username}&run=0`;
    })
  }

  function prevPage (pageCode) {
    pageCode--;
    window.location.href = `/pushup/paging?limitNum=5&pageCode=${pageCode}`
  }

  function nextPage (pageCode) {
    // alert(1)
    pageCode++;
    window.location.href = `/pushup/paging?limitNum=5&pageCode=${pageCode}`
  }
</script>
</body>
</html>
